package logic

import (
	"context"
	"house_srv/house"
	"house_srv/internal/svc"
	"house_srv/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type RentAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RentAddLogic {
	return &RentAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 预约发布
func (l *RentAddLogic) RentAdd(in *house.RentAddRequest) (*house.RentAddResponse, error) {
	// todo: add your logic here and delete this line
	rents := models.Rent{
		UserId:  in.UserId,
		HouseId: int(in.HouseId),
		MidMan:  in.MindMan,
		Tel:     in.Tel,
	}
	models.DB.Debug().Create(&rents)
	return &house.RentAddResponse{
		Id: int64(rents.ID),
	}, nil
}
